﻿
using System.Windows.Forms;

namespace CutShuFa.AutoAction
{
    public class MatParameterControl : TempUserControl, IParameterControl
    {
        private ComboBox comboBox;
        private Parameter _parameter;
        private string[] items;

        public MatParameterControl() : base()
        {
            items = new string[] { "src_mat", "tmp_mat", "gray_mat" };
            comboBox = new ComboBox();
            comboBox.Items.AddRange(items);
            comboBox.SelectedIndex = 0;
            panel.Controls.Add(comboBox);
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        public Parameter GetParameter()
        {
            _parameter.Value = comboBox.SelectedItem as string;
            return _parameter;
        }

        public void Init(Parameter parameter)
        {
            _parameter = parameter;
            if (string.IsNullOrEmpty(parameter.Value))
            {
                return;
            }
            int idx = 0;
            for (int i = 0; i < items.Length; i++)
            {
                if (items[i] == parameter.Value)
                {
                    idx = i;
                    break;
                }
            }
            comboBox.SelectedIndex = idx;
            lb_title.Text = parameter.Name;
        }
    }
}